
## 安装依赖

前提：如果要启用视频功能，请安装`ffmpeg`，确保`ffmpeg`、`ffprobe`可执行程序在`PATH`下

```
npm install 
```

### 傻瓜使用

```javascript
const path=require('path');
const express=require('express');
const Skeleton=require('all-round-skeleton');
const config=require('./config')

class MySkeleton extends Skeleton{
    constructor(opts){
        super(opts);
    }

    serveStaticFiles(){
        const app=this.app;
        const config=this.config;
        super.serveStaticFiles();
    }
}

const skeleton =new Skeleton({config});
skeleton.run();
```

### 自定义主题

Skeleton也支持像`WordPress`那样支持自定义主题。比如，假设我们有一个`skeleton-demo`项目，可以在根目录下建立`/frontend/themes`文件夹，用于存放各种不同主题的文件。不妨为主题起名为`itminus`，在其中建立两个文件夹：
* views/  #各个模板
* static/ #静态文件

最后，在配置文件里填好相关路径，传递给`Skeleton`构造函数即可：
```javascript
// ...
config.basePath={
    "views":[
        path.join(__dirname,"../frontend/themes/itminus/views"),
    ],
    "assets":[
        path.join(__dirname,"../frontend/themes/itminus/static"),
    ],
    "ebooks":"C:/Users/itminus/pdfs",
    "lock":process.cwd(),
};

const skeleton =new Skeleton({config});
skeleton.run();
```

[演示如何自定义主题的demo](https://github.com/newbienewbie/skeleton-demo)

### 扩展功能

要新增或者修改功能，需要对`Skelton`进行扩展。基本的扩展点如下：

```javascript

class MySkeleton extends Skeleton{
    constructor(opts){
        super(opts);
        // 会继承到如下属性：
        // this.config         : 配置缓存
        // ...
        // this.register       : 内置的路由注册器，可以向 this.app 注册路由
        // this.service        : 内置的服务层
        // this.domain         : 内置的数据模型层
        // ...
        // this.app            : 就是简单的express()生成的app！
        // this.staticHandle   : 静态文件处理器
        // ...
    }

    beforeRun(){
        // ...
        // 这里默认会配置模板、注册路由 ...
    }

    serveStaticFiles(){
        const app=this.app;
        const config=this.config;
        // 可以简单的调用父类方法，甚至完全重写
        super.serveStaticFiles();
    }

    afterRun(server,ip,port){
        // ...
    }
}
```

